package rjgc.mall.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import rjgc.mall.entity.Address;
import rjgc.mall.mapper.AddressMapper;
import rjgc.mall.service.AddressService;

import java.util.List;

@Service
public class AddressServiceImpl implements AddressService {
    @Autowired
    private AddressMapper addressMapper;
    @Override
    public void addAddress(String address, Integer userid) {
        Address position = new Address();
        position.setAddress(address);
        position.setUserid(userid);
        position.setSelected(0);
        addressMapper.addAddress(position);
    }

    @Override
    public void deleteAddress(Integer id) {
        addressMapper.deleteAddress(id);
    }

    @Override
    public void setAddress(Integer id,Integer userid) {
        addressMapper.cancelAll(userid);
        addressMapper.setOne(id);
    }

    @Override
    public List<Address> showAddressByUserId(Integer userid) {
        List<Address> areaList= addressMapper.showAddressByUserId(userid);
        return areaList;
    }

    @Override
    public Address showUserSelectAddress(Integer userid) {
        return addressMapper.showUserSelectAddress(userid);
    }
}
